package com.pub;
/*翻页实现类
 * version 1.0
 * created by limingjun
 * 2008-9-25
 */


public class PageRoll{

	private int totalCount = 0;//总记录数

	private int pageSize = GloabPara.pageSize ;//每页记录数	

	private int firstPage=1;//首页页码
	
	private int previousPageNum=0;//上页码
	
	private int currentPageNum = 1;//当前页码
	
	private int nextPageNum=0;//下页码

	private int totalPage = 1;//总页数


	/*
	 * 计算总页数
	 * 参数：
	 * 	totalCount:总记录数
	 */
	public void calculateTotalPage(int totalCount){
		totalPage = totalCount/pageSize;
		if(totalCount%pageSize!=0){
			totalPage++;
		}
		totalPage=(totalPage==0)?1:totalPage;
	}
	/*
	 * 页码计算
	 * 参数：
	 * 	currentPageNum:当前页码
	 */
	public void calculatePageNum(int currentPageNum)
	{
		if(totalPage>0)
		{
			this.currentPageNum=currentPageNum;
			previousPageNum=(currentPageNum==1)?currentPageNum:currentPageNum-1;
			nextPageNum=(currentPageNum==totalPage)?currentPageNum:currentPageNum+1;
		}
	}


	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPreviousPageNum() {
		return previousPageNum;
	}

	public void setPreviousPageNum(int previousPageNum) {
		this.previousPageNum = previousPageNum;
	}

	public int getNextPageNum() {
		return nextPageNum;
	}

	public void setNextPageNum(int nextPageNum) {
		this.nextPageNum = nextPageNum;
	}
	public int getFirstPage() {
		return firstPage;
	}
	public void setFirstPage(int firstPage) {
		this.firstPage = firstPage;
	}
	public int getCurrentPageNum() {
		return currentPageNum;
	}
	public void setCurrentPageNum(int currentPageNum) {
		this.currentPageNum = currentPageNum;
	}	
}
